package com.atguigu.listener;

import com.atguigu.utils.PropertiesUtils;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

/**
 * @author Chen
 * @Description
 * @Version
 * @create 2021-10-19-17:50
 */
@WebListener
public class StartListener implements ServletContextListener {
    @Override
    public void contextInitialized(ServletContextEvent sce) {
        ServletContext servletContext = sce.getServletContext();
        String viewPath = PropertiesUtils.readProperties("viewUrl");
        String staticPath = PropertiesUtils.readProperties("staticUrl");
        servletContext.setAttribute("viewUrl", servletContext.getContextPath()+viewPath);
        servletContext.setAttribute("staticUrl", servletContext.getContextPath()+staticPath);

    }
}
